const request = require('supertest'),
  app = require("../app.js")

describe('#test koa app', () => {
  let server = app.listen(9900)

  describe('#test server', () => {

    it('#test GET /', async () => {
      let res = await request(server)
        .get('/')
        .expect('Content-Type', /text\/html/)
        .expect(200)
        .end((err, res) => {
          if (err) throw err
        })
    })

    it('#test GET /static/lib/jquery/dist/jquery.js', async () => {
      let res = await request(server)
        .get('/static/lib/jquery/dist/jquery.js')
        .expect('Content-Type', /application\/javascript/)
        .expect(200)
        .end((err, res) => {
          if (err) throw err
        })
    })

    it('#test GET /hello/:name', async () => {
      let res = await request(server)
        .get('/hello/docker')
        .expect('Content-Type', /text\/plain/)
        .expect(200)
        .end((err, res) => {
          if (err) throw err
        })
    })
  })
})
